<?php
namespace Admin\Models\lm;
use Admin\Models\BaseModel;
class XHLmCar extends BaseModel
{
    /**
     *
     * @var integer
     * @Primary
     * @Column(type="integer", length=11, nullable=false)
     */
    public $iCarId;

    /**
     *
     * @var string
     * @Column(type="string", length=50, nullable=true)
     */
    public $sCarName;

    /**
     *
     * @var string
     * @Column(type="string", length=30, nullable=true)
     */
    public $sPlateNum;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iPersonNum;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bDelete;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tCreateDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tLastModifyDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iLastModifyUserId;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSource("XHLm_Car");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHLm_Car';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHLmCar[]|XHLmCar|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHLmCar|\Phalcon\Mvc\Model\ResultInterface
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    public static function getCarEnum(){
        $objs=self::find([
            'columns'=>'iCarId,sCarName,sPlateNum,iPersonNum',
            'conditions'=>'bDelete=0',
        ])->toArray();
        $array=[];
        foreach ($objs as $value){
            $array[$value['iCarId']]=$value['sCarName'].'('.$value['sPlateNum'].')限载'.$value['iPersonNum'].'人';
        }
        return $array;
    }

    public static function getPlate(){
        $objs=self::find([
            'columns'=>'iCarId,sCarName,sPlateNum,iPersonNum',
            'conditions'=>'bDelete=0',
        ])->toArray();
        return array_column($objs,'sPlateNum','iCarId');
    }
}
